<template>
    <div class="swiper-container">
        <div class="swiper-wrapper">
            <div class="swiper-slide" v-for="str in listImg" :key="str.id">
              <img :src="str.url"/>
            </div>
        </div>
        <div class="swiper-pagination" v-show="listImg.length>1"></div>
    </div>
</template>
<script>
    import Swiper from 'swiper';
    import 'swiper/dist/css/swiper.min.css';
    export default {
        props: ['listImg'],
        mounted() {
          var option;
          if (this.listImg.length > 1) {
              option = {
                  pagination: '.swiper-pagination',
                  loop: true,
                  autoplay: 3000,
                  onTouchEnd: function() {
                    swiper.startAutoplay()
                  }
              }
          } else {
              option = {
                pagination: '.swiper-pagination'
              }   
          }
          var swiper = new Swiper('.swiper-container', option);  
        }
    }
</script>
<style lang="stylus">
    .swiper-container {width: 100%;height: 100%;}
    .swiper-container .swiper-pagination-bullet{background: #fff;}
	.swiper-container .swiper-pagination-bullet-active {background: #d1a185;}
    
</style>
